var net = require('net');

var client = net.connect({port: 9000}, function() {
    console.log('连接到服务器！');
    client.write("This is from client.")    // 向服务器推送消息
});

var time = 1
client.on('data', function(data) {
	console.log("Times " + time++);
	console.log(data.toString());
	if (time==3)
	{
		client.end();
	}
});

client.on('end', function() { 
   console.log('断开与服务器的连接');
});